import com.alibaba.fastjson.JSON;
import com.tc.report.IntersectReport;
import com.tc.report.intersect.IntersectReportImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class testReport {

    @Test
    public void demo1() throws Exception{
        IntersectReportImpl r=new IntersectReportImpl();
        r.addRowField("地区","","");
        r.addRowField("销售人","地区","");

        r.addColField("产品名","","");

        r.addValField("销售额度","","");
        r.addValField("费用","销售额度","");
        List<Map<String,Object>> l=new ArrayList<>();
        Map<String,Object> map=new HashMap<>();
        map.put("地区","伊春");
        map.put("客户名","大唐");
        map.put("销售人","田才");
        map.put("产品名","苹果");
        map.put("销售额度",100);
        map.put("费用",1);

        Map<String,Object> map2=new HashMap<>();
        map2.put("地区","哈尔滨");
        map2.put("客户名","美丽说");
        map2.put("销售人","王五");
        map2.put("产品名","橘子");
        map2.put("销售额度",300);
        map2.put("费用",2);


        Map<String,Object> map3=new HashMap<>();
        map3.put("地区","加格达奇");
        map3.put("客户名","美丽说");
        map3.put("销售人","李三");
        map3.put("产品名","苹果");
        map3.put("销售额度",200);
        map3.put("费用",3);

        l.add(map);
        l.add(map2);
        l.add(map3);
/*        Map<String,Object> map1=new HashMap<>();
        map1.put("第一列","张三");
        map1.put("第一个月",221);
        map1.put("汇总",10);
        l.add(map1);*/
        Map<String, Object> reportResult = r.findReportResult(l);
        System.out.println(JSON.toJSONString(reportResult));
        System.out.println(r.getRowAreaHandle().outFieldList());
    }

    @Test
    public void demo2() throws Exception{
        IntersectReportImpl r=new IntersectReportImpl();
        r.addColField("第一列","","");
        r.addColField("第二列","第一列","");
        r.addColField("第三列","第二列","");

        List<Map<String,Object>> l=new ArrayList<>();
        Map<String,Object> map=new HashMap<>();
        map.put("第一列","10");
        map.put("第二列",20);
        map.put("第三列",30);
        l.add(map);
        Map<String, Object> reportResult = r.findReportResult(l);
        System.out.println(JSON.toJSONString(reportResult));
        System.out.println(r.getColAreaHandle().outFieldList());
    }

    @Test
    public void demo3() throws Exception{
        IntersectReportImpl r=new IntersectReportImpl();
        r.addValField("第一列","","");
        r.addValField("第二列","第一列","");
        r.addValField("-第二列","第一列","");
        r.addValField("第三列","-第二列","");
/*        r.addColField("10","","");
        r.addColField("20","第一列","");
        r.addColField("第三列","第二列","");*/
        List<Map<String,Object>> l=new ArrayList<>();
        Map<String,Object> map=new HashMap<>();
        map.put("第一列","10");
        map.put("第二列",20);
        map.put("第三列",30);
        l.add(map);
        Map<String, Object> reportResult = r.findReportResult(l);
        System.out.println(JSON.toJSONString(reportResult));
    }

}
